package com.bawei.yangzongcai___day2.MaiDongFangHong.day8;

import java.net.HttpCookie;

import okhttp3.OkHttpClient;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * create by ertu
 * create on 2021/7/31
 * description
 */
public class KotlinHttp {

    public  static  KotlinHttp kotlinHttp;

    public static KotlinHttp getkotlinhttp()
    {
        if (kotlinHttp==null)
        {
            kotlinHttp = new KotlinHttp();

        }
        return kotlinHttp;
    }



    public Retrofit retrofit(String url)
    {
        return new Retrofit.Builder()
                .baseUrl(url)
                .client(new OkHttpClient.Builder()
                        .addInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
                .build())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();

    }
}
